package com.service.Impl;

import com.dao.NewsDao;
import com.mypg.News;
import com.service.NewsService;

import java.sql.Timestamp;
import java.util.List;

public class NewsServiceImpl implements NewsService {

    private NewsDao newsDao;

    public NewsServiceImpl(){}
    public NewsServiceImpl(NewsDao newsDao) {
        this.newsDao = newsDao;
    }

    @Override
    public List<News> selectAllNews() {
        return newsDao.selectAllNews();
    }

    @Override
    public News selectNewsByNews_id(int news_id) {
        return newsDao.selectNewsByNews_id(news_id);
    }

    @Override
    public List<News> selectNewsFor_news_table_jsp(String news_class, Timestamp time_start, Timestamp time_end, int start_row, int page_nums) {
        return newsDao.selectNewsFor_news_table_jsp(news_class,time_start,time_end,start_row,page_nums);
    }

    @Override
    public List<News> selectRelativeNews(String news_class, int news_id) {
        return newsDao.selectRelativeNews(news_class,news_id);
    }

    @Override
    public int selectNews_count_For_news_table_jsp(String news_class, Timestamp time_start, Timestamp time_end) {
        return newsDao.selectNews_count_For_news_table_jsp(news_class,time_start,time_end);
    }

    @Override
    public int selectNews_count() {
        return newsDao.selectNews_count();
    }

    @Override
    public void insertNews(News news) {
        newsDao.insertNews(news);
    }

    @Override
    public void deleteNewsByNews_id(int news_id) {
        newsDao.deleteNewsByNews_id(news_id);
    }

    @Override
    public void updateNewsByNews_id(News news) {
        newsDao.updateNewsByNews_id(news);
    }

    @Override
    public void updateNews_imgByNews_id(String news_img, int news_id) {
        newsDao.updateNews_imgByNews_id(news_img,news_id);
    }

    @Override
    public void updateNews_readByNews_id(int news_id) {
        newsDao.updateNews_readByNews_id(news_id);
    }

    public NewsDao getNewsDao() {
        return newsDao;
    }

    public void setNewsDao(NewsDao newsDao) {
        this.newsDao = newsDao;
    }
}
